package com.example.controller;

import com.example.entity.Motion;
import com.example.service.MotionService;
import com.example.utils.QueryInfo;
import com.example.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 运动动作控制层
 * @Comment：最难的一次作业
 * @Date: 2023/12/15
 */
@RestController
@RequestMapping("/motion")
@Api(tags = "运动类型管理")
public class MotionController {

    @Autowired
    private MotionService motionService;

    @ApiOperation(value = "分页查询运动类型")
    @PostMapping("/findPage")
    public Result findAll(@RequestBody QueryInfo queryInfo) {
        return motionService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加运动类型")
    @PostMapping("/add")
    public Result add(@RequestBody Motion sport) {
        return motionService.add(sport);
    }

    @ApiOperation(value = "修改运动类型")
    @PostMapping("/edit")
    public Result edit(@RequestBody Motion sport) {
        return motionService.edit(sport);
    }

    @ApiOperation(value = "删除运动类型")
    @DeleteMapping("delete")
    public Result delete(Long id) {
        return motionService.delete(id);
    }

    @ApiOperation(value = "查询某个运动类型")
    @GetMapping("/{id}")
    public Result findInfo(@PathVariable Long id) {
        return motionService.findInfo(id);
    }


}
